<?php

include_package( 'Xml' );

class XmlDatabasePrimaryKeyElement extends XmlElement {

	function XmlDatabasePrimaryKeyElement( &$oConfiguration, &$oPrimaryKey ) {

		$this->XmlElement( 'primaryKey' );
		$this->AddAttribute( 'name', $oPrimaryKey->GetName() );
		$this->AddAttribute( 'id'  , $oPrimaryKey->GetName() );
		
		if ( $oConfiguration->GetProperty( 'ShowPrimaryKeyColumns' ) ) {
			foreach( $oPrimaryKey->GetColumnNames() as $iSequence => $sThisColumn ) {
				$oPrimaryKeyColumn = new XmlElement( 'primaryKeyColumn' );
				$oPrimaryKeyColumn->AddAttribute( 'columnId' , $oPrimaryKey->GetTableName() . '.' . $sThisColumn );
				$oPrimaryKeyColumn->AddAttribute( 'sequence' , $iSequence );
				$this->AddElement( $oPrimaryKeyColumn );
			}
		}
	}
}

require_once( 'XmlDatabaseColumnElement.php' );
	
?>
